package com.biz.primus.common.utils;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * 使用jackson
 * Created @ClassName: JsonUtil By @author jun.liu 
 * @date 2016年7月12日 上午10:58:35
 * @reviewer shutao.gong
 * @Deprecated 现在使用JsonUtils
 */
@Deprecated
public class JsonUtil extends JsonUtils{

    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

    static {
        OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    }

    public static <T> T json2Obj(String jsonStr, Class<T> clazz) {
        if (jsonStr == null) {
            return null;
        }
        try {
            return OBJECT_MAPPER.readValue(jsonStr, clazz);
        } catch (Exception e) {
            throw new RuntimeException("Json反序列化出错", e);
        }
    }

 	@SuppressWarnings({ "rawtypes", "deprecation" })
	public static <T> T json2Obj(String content, Class<T> clazzItem, Class... classes) {
         if (org.apache.commons.lang3.StringUtils.isBlank(content)) {
             return null;
         }
         JavaType javaType  = OBJECT_MAPPER.getTypeFactory().constructParametricType(clazzItem, classes);
         try {
             return OBJECT_MAPPER.readValue(content, javaType);
         } catch (Exception e) {
             throw new RuntimeException("Json反序列化出错", e);
         }
 	}
 	
    public static String obj2Json(Object obj) {
        return JsonUtils.obj2Json(obj);
    }




}
